package com.s3s.ssm.view.cashier;

import java.awt.EventQueue;

import javax.swing.JButton;
import javax.swing.JFrame;

import org.jdesktop.swingx.JXMultiSplitPane;
import org.jdesktop.swingx.MultiSplitLayout;
import org.jdesktop.swingx.MultiSplitLayout.ColSplit;
import org.jdesktop.swingx.MultiSplitLayout.Divider;
import org.jdesktop.swingx.MultiSplitLayout.Leaf;
import org.jdesktop.swingx.MultiSplitLayout.Node;
import org.jdesktop.swingx.MultiSplitLayout.RowSplit;
import org.jdesktop.swingx.MultiSplitLayout.Split;

import java.awt.BorderLayout;
import java.util.Arrays;
import java.util.List;

public class Main {

	private static final int DEF_DIVIDER_SIZE = 3;
	private static final String RIGHT_MIDDLE = "right.middle";
	private static final String RIGHT_TOP = "right.top";
	private static final String RIGHT_BOTTOM = "right.bottom";
	private static final String LEFT_BOTTOM = "left.bottom";
	private static final String LEFT_MIDDLE = "left.middle";
	private static final String LEFT_TOP = "left.top";
	private JFrame frame;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Main window = new Main();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Main() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JXMultiSplitPane multiSplitPane = new JXMultiSplitPane();
		frame.getContentPane().add(multiSplitPane, BorderLayout.CENTER);

		ColSplit leftCol = new ColSplit();
		ColSplit rightCol = new ColSplit();
		
		leftCol.setWeight(0.5);
		rightCol.setWeight(0.5);
		multiSplitPane.setDividerSize(DEF_DIVIDER_SIZE);

		List<Node> leftChildren = Arrays
				.asList(new Leaf(LEFT_TOP), new Divider(), new Leaf(
						LEFT_MIDDLE), new Divider(), new Leaf(LEFT_BOTTOM));
		List<Node> rightChildren = Arrays
				.asList(new Leaf(RIGHT_TOP), new Divider(), new Leaf(
						RIGHT_MIDDLE), new Divider(), new Leaf(RIGHT_BOTTOM));

		leftCol.setChildren(leftChildren);
		rightCol.setChildren(rightChildren);
		
		Split modelRoot = new RowSplit();
		modelRoot.setChildren(leftCol, new Divider(), rightCol);

		multiSplitPane.getMultiSplitLayout().setModel(modelRoot);
		multiSplitPane.add(new InvoiceScreen(), LEFT_TOP);
		multiSplitPane.add(new AreaPanel(), LEFT_MIDDLE);
		multiSplitPane.add(new TablePane(), LEFT_BOTTOM);
		multiSplitPane.add(new DishGroupPanel(), RIGHT_TOP);
		multiSplitPane.add(new DishPanel(), RIGHT_MIDDLE);
		multiSplitPane.add(new CalculatorPanel(), RIGHT_BOTTOM);
	}

}
